package harima.collision.bodies;

public class PlatformUpdater extends BodyUpdater {

	PlatformBody updatedBody;
	PlatformPath path;


	public PlatformUpdater(PlatformBody _updatedBody, PlatformPath _path) {
		super(_updatedBody);
		updatedBody = _updatedBody;
		path = _path;
		updatedBody.setMovementDirection(path.getFirstNode().moveDirection);
	}
	

	public void updateBody(long time) {

		if (updatedBody.isSolid()) {
			updatedBody.moveBodiesAbove();
		}
		updatedBody.moveSelft();
		updatePath();
	}

	private void updatePath() {
		if (path != null) {
			if (path.step()) {
				PathNode nextNode = path.nextNode();
				updatedBody.setMovementDirection(nextNode.moveDirection);
			}
		}
	}

}
